package leetcode;

public class _1957 {
    /**
     * 删除字符使字符串变好
     */
    class Solution {
        public String makeFancyString(String s) {
            char[] chars = s.toCharArray();
            StringBuilder q = new StringBuilder();
            int count = 0;
            for(char c:chars){
                if(q.length()>0 && q.charAt(q.length()-1) == c)
                    count++;
                else
                    count = 1;
                if(count < 3)
                    q.append(c);
            }
            return q.toString();
        }
    }

}
